home *** CD-ROM | disk | FTP | other *** search
- /*
- File: SimpleFormatScripting.c
-
- Copyright (c) 1996, Adobe Systems Incorporated.
- All rights reserved.
-
- Scripting functions for SimpleFormat example module.
-
- */
-
- #include "SimpleFormat.h"
-
- /*****************************************************************************/
-
- /* Checks the parameters against scripting-returned parameters, if any, and
- updates our parameters to match ones given to us by the scripting system. */
-
- Boolean ReadScriptParamsOnRead (GPtr globals)
- {
- PIReadDescriptor token = NULL;
- DescriptorKeyID key = 0;
- DescriptorTypeID type = 0;
- OSType shape = 0, create = 0;
- DescriptorKeyIDArray array = { NULLID };
- int32 flags = 0;
- OSErr gotErr = noErr, stickyError = noErr;
- Boolean returnValue = true;
-
- if (DescriptorAvailable())
- { /* playing back. Do our thing. */
- token = OpenReader(array);
- if (token)
- {
- while (PIGetKey(token, &key, &type, &flags))
- {
- switch (key)
- {
- // check keys here
- }
- }
-
- stickyError = CloseReader(&token); // closes & disposes.
-
- if (stickyError)
- {
- if (stickyError == errMissingParameter) // missedParamErr == -1715
- ;
- /* (descriptorKeyIDArray != NULL)
- missing parameter somewhere. Walk IDarray to find which one. */
- else
- gResult = stickyError;
- }
- }
-
- returnValue = PlayDialog();
- /* return TRUE if want to show our Dialog */
- }
-
- return returnValue;
- }
-
- /*****************************************************************************/
-
- /* Checks the parameters against scripting-returned parameters, if any, and
- updates our parameters to match ones given to us by the scripting system. */
-
- Boolean ReadScriptParamsOnWrite (GPtr globals)
- {
- PIReadDescriptor token = NULL;
- DescriptorKeyID key = 0;
- DescriptorTypeID type = 0;
- OSType shape = 0, create = 0;
- DescriptorKeyIDArray array = { NULLID };
- int32 flags = 0;
- OSErr gotErr = noErr, stickyError = noErr;
- Boolean returnValue = true;
-
- if (DescriptorAvailable())
- { /* playing back. Do our thing. */
- token = OpenReader(array);
- if (token)
- {
- while (PIGetKey(token, &key, &type, &flags))
- {
- switch (key)
- {
- // check keys here
- }
- }
-
- stickyError = CloseReader(&token); // closes & disposes.
-
- if (stickyError)
- {
- if (stickyError == errMissingParameter) // missedParamErr == -1715
- ;
- /* (descriptorKeyIDArray != NULL)
- missing parameter somewhere. Walk IDarray to find which one. */
- else
- gResult = stickyError;
- }
- }
-
- returnValue = PlayDialog();
- /* return TRUE if want to show our Dialog */
- }
-
- return returnValue;
- }
-
- /*****************************************************************************/
-
- /* Writes our parameters to the scripting system. */
-
- OSErr WriteScriptParamsOnRead (GPtr globals)
- {
- PIWriteDescriptor token = nil;
- OSErr gotErr = noErr;
-
- if (DescriptorAvailable())
- { /* recording. Do our thing. */
- token = OpenWriter();
- if (token)
- {
- // write keys here
- PIPutBool(token, keyFoo, true);
- gotErr = CloseWriter(&token); /* closes and sets dialog optional */
- /* done. Now pass handle on to Photoshop */
- }
- }
- return gotErr;
- }
-
-
- /*****************************************************************************/
-
- /* Writes our parameters to the scripting system. */
-
- OSErr WriteScriptParamsOnWrite (GPtr globals)
- {
- PIWriteDescriptor token = nil;
- OSErr gotErr = noErr;
-
- if (DescriptorAvailable())
- { /* recording. Do our thing. */
- token = OpenWriter();
- if (token)
- {
- // write keys here
- PIPutBool(token, keyBar, true);
- gotErr = CloseWriter(&token); /* closes and sets dialog optional */
- /* done. Now pass handle on to Photoshop */
- }
- }
- return gotErr;
- }